import { cloudService } from './index'
import { IPassword, IQueryPassword } from '@/types/password'

export const addPasswordApi = (password: IPassword): Promise<boolean> =>
  cloudService({
    url: '/home-api/password',
    method: 'post',
    data: password
  })

export const updatePasswordApi = (id: number, password: IPassword): Promise<boolean> =>
  cloudService({
    url: `/home-api/password/${id}`,
    method: 'put',
    data: password
  })

export const deletePasswordApi = (id: number): Promise<boolean> =>
  cloudService({
    url: `/home-api/password/${id}`,
    method: 'delete'
  })

export const queryPasswordApi = (query: IQueryPassword): Promise<IPassword[]> =>
  cloudService({
    url: '/home-api/password',
    method: 'get',
    params: query
  })

export const queryPasswordCategoryApi = (): Promise<string[]> =>
  cloudService({
    url: '/home-api/password/category',
    method: 'get'
  })
